﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PLC.Domain.Entity;

namespace PLC.Infrastructure.DbContext.Config;

public class DataConfigConfig:IEntityTypeConfiguration<DataConfig>
{
    public void Configure(EntityTypeBuilder<DataConfig> builder)
    {
        builder.ToTable("tb_config_data");
        builder.HasKey(p => p.Id);
        builder.Property(p => p.Id).ValueGeneratedNever();
        builder.HasIndex(p => p.DeviceConfigId);
        builder.Property(p => p.Register).HasMaxLength(128).IsRequired();
        builder.Property(p => p.JudgeValue).IsRequired().HasMaxLength(32).HasDefaultValue("");
        builder.Property(p => p.DataType).IsRequired();
        builder.Property(p => p.Status).IsRequired();
        builder.Property(p => p.DataDescription).HasDefaultValue("").HasMaxLength(1024);
        builder.Property(p => p.OrderNum).IsRequired().HasDefaultValue(0);
    }
}